<template>
  <div class="city">
    <div class="nav-title">选择国家或者地区</div>
    <city-type-list :cityList="cityList"></city-type-list>
    <city-alphabet :letters="letters"></city-alphabet>
  </div>
</template>

<script>
import CityTypeList from './components/typeList'
import CityAlphabet from './components/Alphabet'
export default {
  name: 'CityList',
  components: {
    CityTypeList,
    CityAlphabet
  },
  data() {
    return {
      cityList: []
    }
  },
  methods: {
    async getCityList() {
      try {
        const data = await this.http.get('city')
        console.log(data)
        this.cityList = data.data.Alphabet
      } catch (err) {
        console.log(err)
      }
    }
  },
  created() {
    this.getCityList()
  },
  computed: {
    letters() {
      const letters = []
      for (let i in this.cityList) {
        letters.push(i)
      }
      return letters
    }
  }
}
</script>
<style lang="scss" scoped>
@import '~@/assets/css/city.scss';
</style>
